package cn.e4j.modular.api.controller;


import cn.e4j.core.dto.Dtos;
import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.dto.requestDtoResolver.DtoParam;
import cn.e4j.core.dto.requestDtoResolver.DtoWapper;
import cn.e4j.core.reqres.response.ErrorResponseData;
import cn.e4j.core.reqres.response.ResponseData;
import cn.e4j.core.reqres.response.SuccessResponseData;
import cn.e4j.modular.api.service.Gwat500Service;
import cn.e4j.modular.api.util.ControllerSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 订单运输信息回报 控制类
 * Created by shixc on 2018/5/4.
 */
@RestController
@RequestMapping("api/wx/gwat500")
public class Gwat500Controller extends ControllerSupport {
    private static Logger logger = LoggerFactory.getLogger(Gwat500Controller.class);

    @Autowired
    Gwat500Service gwat500Service;

    /**
     * 根据微信号 获取司机信息
     * @return
     */
    @RequestMapping(value = "getGwaaData")
    public ResponseData getGwaaData(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        List<Dto> list = gwat500Service.getGwaaData(inDto);
        return new SuccessResponseData(list);
    }

    /**
     * 根据输入信息 获取司机信息
     * @return
     */
    @RequestMapping(value = "getGwaaData2")
    public ResponseData getGwaaData2(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        List<Dto> list = gwat500Service.getGwaaData2(inDto);
        return SUCCESS(list);
    }

    /**
     * 获取正式订单明细
     * @return
     */
    @RequestMapping(value = "getGwcsData")
    public ResponseData getGwcsData(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        List<Dto> list = gwat500Service.getGwcsPage(inDto);
        return SUCCESS(list);
    }


    /**
     * 保存订单运输信息回报
     *
     * @return
     */
    @RequestMapping(value = "saveData")
    public ResponseData saveData(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        try {
            gwat500Service.insert(wapper.getSysUser(),inDto);
        } catch (Exception e) {
            e.printStackTrace();
            return new ErrorResponseData("服务器出小差了");
        }
        return new SuccessResponseData();
    }

}
